/*
 * Created by JFormDesigner on Sat Jun 05 14:48:54 CST 2021
 */

package com.J1ay.carsys.gui;

import com.J1ay.carsys.gui.Emp.Login;
import com.J1ay.carsys.gui.User.UserLogin;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout;

/**
 * @author Brainrain
 */
public class Welcome extends JFrame {
    public Welcome() {
        initComponents();
    }

    public void start() {
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    private void bowerActionPerformed(ActionEvent e) {
        // TODO add your code here
        new UserLogin().start();
        // 关闭窗口
        JButton jButton = (JButton) e.getSource();
        Container container = jButton.getParent();
        while (!(container instanceof JFrame)) {
            container = container.getParent();
        }
        ((JFrame)container).dispose();
    }

    private void empActionPerformed(ActionEvent e) {
        // TODO add your code here
        new Login().start();
        // 关闭窗口
        JButton jButton = (JButton) e.getSource();
        Container container = jButton.getParent();
        while (!(container instanceof JFrame)) {
            container = container.getParent();
        }
        ((JFrame)container).dispose();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        label1 = new JLabel();
        label2 = new JLabel();
        bower = new JButton();
        emp = new JButton();
        label3 = new JLabel();

        //======== this ========
        setTitle("\u5c0f\u6c7d\u8f66\u51fa\u79df\u7cfb\u7edf");
        setResizable(false);
        Container contentPane = getContentPane();

        //---- label1 ----
        label1.setText("\u6b22\u8fce\u4f7f\u7528\u5c0f\u6c7d\u8f66\u51fa\u79df\u7cfb\u7edf");

        //---- label2 ----
        label2.setText("\u8bf7\u9009\u62e9\u5165\u53e3");

        //---- bower ----
        bower.setText("\u7528\u6237");
        bower.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                bowerActionPerformed(e);
            }
        });

        //---- emp ----
        emp.setText("\u5458\u5de5");
        emp.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                empActionPerformed(e);
            }
        });

        //---- label3 ----
        label3.setText("Copyright@ by. J1ay");

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(174, 174, 174)
                    .addComponent(label1)
                    .addGap(0, 177, Short.MAX_VALUE))
                .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                    .addContainerGap(120, Short.MAX_VALUE)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                            .addComponent(bower)
                            .addGap(113, 113, 113)
                            .addComponent(emp)
                            .addGap(110, 110, 110))
                        .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                            .addComponent(label3, GroupLayout.PREFERRED_SIZE, 149, GroupLayout.PREFERRED_SIZE)
                            .addGap(159, 159, 159))
                        .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                            .addComponent(label2)
                            .addGap(209, 209, 209))))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addComponent(label1, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(label2)
                    .addGap(44, 44, 44)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(bower)
                        .addComponent(emp))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
                    .addComponent(label3, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JLabel label1;
    private JLabel label2;
    private JButton bower;
    private JButton emp;
    private JLabel label3;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
